{extend name="lib/common_list" /}
{block name="title"}新增管理员{/block}
{block name="css"}
    <link rel="stylesheet" href="/static/plugins/iCheck/custom.css" />
    <style type="text/css">
        li { list-style-type: none;float: left;}
        #dvRoles {width: 600px;}
    </style>
{/block}
{block name="javascript"}
    <script type="text/javascript" src="/static/plugins/iCheck/icheck.min.js"></script>
    <script type="text/javascript">
        function SaveUserRoles() {
            var chkRoles = $("input[type='checkbox']:checked");
            var rolesId = new Array();
            chkRoles.each(function (i) {
                rolesId.push(this.value);
            });
            $.post('{:url("role/assignrolessave")}', { userId: {$userid}, roleIds: rolesId.join(',') }, function (result) {
                if (result.code == 0) {
                    layer.alert('分配成功！', function () {
                        if (typeof (parent.initAcTable) == "function")
                            parent.initAcTable();
                        parent.layer.close(parent.layer_userroles_index)
                    });
                }
                else {
                    layer.alert(result.msg);
                }
            }, 'json');
        }

        $(document).ready(function () {
            $("#cancel").bind("click", function () {
                parent.layer.close(parent.layer_userroles_index);
            });
            $(".i-checks").iCheck({ checkboxClass: "icheckbox_square-green", radioClass: "iradio_square-green", });
        });
    </script>
{/block}
{block name="content"}
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
                <h3>角色名称：</h3>                
                <ul>
                    {$rolehtml}
                </ul>
            </div>
        </div>
        <div class="row" style="text-align:center;">
            <button class="btn btn-primary" onclick="SaveUserRoles();" type="button">提交</button>
            <button class="btn btn-white" id="cancel" type="button">取消</button>
        </div>
    </div>      
{/block}